;!function (t) {
    "use strict";
    function e(t, e) {
        var i = (65535 & t) + (65535 & e);
        return (t >> 16) + (e >> 16) + (i >> 16) << 16 | 65535 & i
    }

    function i(t, e) {
        return t << e | t >>> 32 - e
    }

    function s(t, s, n, a, o, r) {
        return e(i(e(e(s, t), e(a, r)), o), n)
    }

    function n(t, e, i, n, a, o, r) {
        return s(e & i | ~e & n, t, e, a, o, r)
    }

    function a(t, e, i, n, a, o, r) {
        return s(e & n | i & ~n, t, e, a, o, r)
    }

    function o(t, e, i, n, a, o, r) {
        return s(e ^ i ^ n, t, e, a, o, r)
    }

    function r(t, e, i, n, a, o, r) {
        return s(i ^ (e | ~n), t, e, a, o, r)
    }

    function h(t, i) {
        t[i >> 5] |= 128 << i % 32, t[14 + (i + 64 >>> 9 << 4)] = i;
        var s, h, l, c, d, u = 1732584193, p = -271733879, m = -1732584194, g = 271733878;
        for (s = 0; s < t.length; s += 16)h = u, l = p, c = m, d = g, u = n(u, p, m, g, t[s], 7, -680876936), g = n(g, u, p, m, t[s + 1], 12, -389564586), m = n(m, g, u, p, t[s + 2], 17, 606105819), p = n(p, m, g, u, t[s + 3], 22, -1044525330), u = n(u, p, m, g, t[s + 4], 7, -176418897), g = n(g, u, p, m, t[s + 5], 12, 1200080426), m = n(m, g, u, p, t[s + 6], 17, -1473231341), p = n(p, m, g, u, t[s + 7], 22, -45705983), u = n(u, p, m, g, t[s + 8], 7, 1770035416), g = n(g, u, p, m, t[s + 9], 12, -1958414417), m = n(m, g, u, p, t[s + 10], 17, -42063), p = n(p, m, g, u, t[s + 11], 22, -1990404162), u = n(u, p, m, g, t[s + 12], 7, 1804603682), g = n(g, u, p, m, t[s + 13], 12, -40341101), m = n(m, g, u, p, t[s + 14], 17, -1502002290), p = n(p, m, g, u, t[s + 15], 22, 1236535329), u = a(u, p, m, g, t[s + 1], 5, -165796510), g = a(g, u, p, m, t[s + 6], 9, -1069501632), m = a(m, g, u, p, t[s + 11], 14, 643717713), p = a(p, m, g, u, t[s], 20, -373897302), u = a(u, p, m, g, t[s + 5], 5, -701558691), g = a(g, u, p, m, t[s + 10], 9, 38016083), m = a(m, g, u, p, t[s + 15], 14, -660478335), p = a(p, m, g, u, t[s + 4], 20, -405537848), u = a(u, p, m, g, t[s + 9], 5, 568446438), g = a(g, u, p, m, t[s + 14], 9, -1019803690), m = a(m, g, u, p, t[s + 3], 14, -187363961), p = a(p, m, g, u, t[s + 8], 20, 1163531501), u = a(u, p, m, g, t[s + 13], 5, -1444681467), g = a(g, u, p, m, t[s + 2], 9, -51403784), m = a(m, g, u, p, t[s + 7], 14, 1735328473), p = a(p, m, g, u, t[s + 12], 20, -1926607734), u = o(u, p, m, g, t[s + 5], 4, -378558), g = o(g, u, p, m, t[s + 8], 11, -2022574463), m = o(m, g, u, p, t[s + 11], 16, 1839030562), p = o(p, m, g, u, t[s + 14], 23, -35309556), u = o(u, p, m, g, t[s + 1], 4, -1530992060), g = o(g, u, p, m, t[s + 4], 11, 1272893353), m = o(m, g, u, p, t[s + 7], 16, -155497632), p = o(p, m, g, u, t[s + 10], 23, -1094730640), u = o(u, p, m, g, t[s + 13], 4, 681279174), g = o(g, u, p, m, t[s], 11, -358537222), m = o(m, g, u, p, t[s + 3], 16, -722521979), p = o(p, m, g, u, t[s + 6], 23, 76029189), u = o(u, p, m, g, t[s + 9], 4, -640364487), g = o(g, u, p, m, t[s + 12], 11, -421815835), m = o(m, g, u, p, t[s + 15], 16, 530742520), p = o(p, m, g, u, t[s + 2], 23, -995338651), u = r(u, p, m, g, t[s], 6, -198630844), g = r(g, u, p, m, t[s + 7], 10, 1126891415), m = r(m, g, u, p, t[s + 14], 15, -1416354905), p = r(p, m, g, u, t[s + 5], 21, -57434055), u = r(u, p, m, g, t[s + 12], 6, 1700485571), g = r(g, u, p, m, t[s + 3], 10, -1894986606), m = r(m, g, u, p, t[s + 10], 15, -1051523), p = r(p, m, g, u, t[s + 1], 21, -2054922799), u = r(u, p, m, g, t[s + 8], 6, 1873313359), g = r(g, u, p, m, t[s + 15], 10, -30611744), m = r(m, g, u, p, t[s + 6], 15, -1560198380), p = r(p, m, g, u, t[s + 13], 21, 1309151649), u = r(u, p, m, g, t[s + 4], 6, -145523070), g = r(g, u, p, m, t[s + 11], 10, -1120210379), m = r(m, g, u, p, t[s + 2], 15, 718787259), p = r(p, m, g, u, t[s + 9], 21, -343485551), u = e(u, h), p = e(p, l), m = e(m, c), g = e(g, d);
        return [u, p, m, g]
    }

    function l(t) {
        var e, i = "";
        for (e = 0; e < 32 * t.length; e += 8)i += String.fromCharCode(t[e >> 5] >>> e % 32 & 255);
        return i
    }

    function c(t) {
        var e, i = [];
        for (i[(t.length >> 2) - 1] = undefined, e = 0; e < i.length; e += 1)i[e] = 0;
        for (e = 0; e < 8 * t.length; e += 8)i[e >> 5] |= (255 & t.charCodeAt(e / 8)) << e % 32;
        return i
    }

    function d(t) {
        return l(h(c(t), 8 * t.length))
    }

    function u(t, e) {
        var i, s, n = c(t), a = [], o = [];
        for (a[15] = o[15] = undefined, n.length > 16 && (n = h(n, 8 * t.length)), i = 0; i < 16; i += 1)a[i] = 909522486 ^ n[i], o[i] = 1549556828 ^ n[i];
        return s = h(a.concat(c(e)), 512 + 8 * e.length), l(h(o.concat(s), 640))
    }

    function p(t) {
        var e, i, s = "0123456789abcdef", n = "";
        for (i = 0; i < t.length; i += 1)e = t.charCodeAt(i), n += s.charAt(e >>> 4 & 15) + s.charAt(15 & e);
        return n
    }

    function m(t) {
        return unescape(encodeURIComponent(t))
    }

    function g(t) {
        return d(m(t))
    }

    function v(t) {
        return p(g(t))
    }

    function f(t, e) {
        return u(m(t), m(e))
    }

    function _(t, e) {
        return p(f(t, e))
    }

    function w(t, e, i) {
        return e ? i ? f(e, t) : _(e, t) : i ? g(t) : v(t)
    }

    t.md5 = w
}(this), function (t, e) {
    "use strict";
    function i(t) {
        if (!(arguments.length < i.length) && t && (this.options = t || {}, this.options.src)) {
            switch (this._isComplete = !1, this._image = new Image, this._image.crossOrigin = null, this._image.src = this.options.src, !0) {
                case this.options.quality === e || isNaN(this.options.quality):
                case this.options.quality > 1 || this.options.quality < 0:
                    this.options.quality = 1;
                    break;
                default:
                    this.options.quality = +this.options.quality
            }
            if (this.options.coordinate === e || 4 === this.options.coordinate.length) {
                this.options.isMoving === e && (this.options.isMoving = !0), this.options.isMouseWheel === e && (this.options.isMouseWheel = !0), this.options.isResize === e && (this.options.isResize = !1), this.options.fillStyle === e && (this.options.fillStyle = "white");
                var s = this;
                if (s._image.complete)s._isComplete = !0, s._init(); else var n = setInterval(function () {
                    s._image.complete && (clearInterval(n), s._isComplete = !0, s._init())
                }, 10)
            }
        }
    }

    i.prototype = {
        constructor: i, _init: function () {
            this._setInitialParam(), this.options.canvas === e ? this._canvasBox = document.createElement("canvas") : this._canvasBox = this.options.canvas, this.options.coordinate !== e && (this.options.coordinate = this.options.coordinate.map(function (t) {
                return parseInt(t)
            }));
            var t, i = !0;
            this.options.isResize ? (this.options.canvasW === e && (this.options.canvasW = 1600), this.options.canvasH === e && (this.options.canvasH = 1200)) : this.options.coordinate !== e ? (t = this._limitMaxScaler(this.options.coordinate[2], this.options.coordinate[3]), this.options.canvasW = t.newW, this.options.canvasH = t.newH) : (t = this._limitMaxScaler(this._image.width, this._image.height), this.options.canvas === e && this.options.canvasW === e && this.options.canvasH === e && (i = !1), this.options.canvas !== e && this.options.canvasW !== e || (this.options.canvasW = this._image.width), this.options.canvas !== e && this.options.canvasH !== e || (this.options.canvasH = this._image.height)), i || (this.options.canvasW = t.newW, this.options.canvasH = t.newH), this._element = this._canvasBox.getContext("2d"), this._canvasBox.width = this.options.canvasW, this._canvasBox.height = this.options.canvasH;
            var s = this._zipImage(this.options.canvasW, this.options.canvasH);
            this._w = s.w, this._h = s.h, this._reset(), this._element.setTransform(1, 0, 0, 1, 0, 0), this._element.translate(this._canvasBox.width / 2, this._canvasBox.height / 2), this._drawImage(), this.options.canvas !== e && this.options.coordinate === e && this._bindEvt()
        }, isComplete: function () {
            return this._isComplete
        }, _limitMaxScaler: function (t, i) {
            var s = this.options.maxImageW, n = this.options.maxImageH, a = 1, o = t / i, r = 1;
            switch (!0) {
                case s !== e && n !== e:
                    a = s / n;
                    break;
                case s !== e:
                    a = 0;
                    break;
                case n !== e:
                    a = Infinity;
                    break;
                default:
                    a = o
            }
            var h, l;
            return t > s || i > n ? o >= a && t > s ? (h = s, l = s / o, r = s / t) : o < a && i > n && (l = n, h = n * o, r = n / i) : (h = t, l = i), {
                newW: h,
                newH: l,
                scaler: r
            }
        }, _setInitialParam: function () {
            this._currentScale = 1, this._currentAngle = 0, this._startX = 0, this._startY = 0, this._w = 0, this._h = 0
        }, _drawImage: function () {
            if (this.clear(), this._element.save(), this._element.scale(this._currentScale, this._currentScale), this._element.rotate(this._currentAngle * Math.PI / 180), this.options.coordinate === e)this._element.drawImage(this._image, -this._w / 2, -this._h / 2, this._w, this._h); else {
                var t = this.options.coordinate, i = t[0], s = t[1], n = t[2], a = t[3];
                this._element.drawImage(this._image, i, s, n, a, -this._canvasBox.width / 2, -this._canvasBox.height / 2, this._canvasBox.width, this._canvasBox.height)
            }
            this._element.restore(), this.options.newImage !== e && (this.options.newImage.src = this.saveUrl())
        }, clear: function () {
            this._element.save(), this._element.setTransform(1, 0, 0, 1, 0, 0), this._element.clearRect(0, 0, this._canvasBox.width, this._canvasBox.height), this.options.fillStyle !== e && (this._element.fillStyle = this.options.fillStyle, this._element.fillRect(0, 0, this._canvasBox.width, this._canvasBox.height)), this._element.restore()
        }, _getMousePos: function (t) {
            var e = this._canvasBox.getBoundingClientRect();
            return {x: t.clientX - e.left, y: t.clientY - e.top}
        }, _reset: function () {
            this.clear(), this._currentScale = 1, this._currentAngle = 0
        }, _zipImage: function (t, e) {
            var i = this._image.width / this._image.height, s = this.options.canvasW / this.options.canvasH, n = this._image.width, a = this._image.height;
            return i >= s ? (n = t, a = n / i) : (a = e, n = a * i), {w: n, h: a}
        }, saveUrl: function () {
            return this.options.canvas && !this.options.isResize ? this._newCanvas() : this._canvasBox.toDataURL("image/jpeg", this.options.quality)
        }, _newCanvas: function () {
            var t = document.createElement("canvas"), e = t.getContext("2d");
            this._currentAngle % 90 != 0 && (this._currentAngle = this._currentAngle - this._currentAngle % 90);
            var i = this._currentAngle / 90 % 2 == 0 ? this._image.width : this._image.height, s = this._currentAngle / 90 % 2 == 0 ? this._image.height : this._image.width, n = this._limitMaxScaler(i, s), a = n.scaler;
            return t.width = n.newW, t.height = n.newH, e.setTransform(1, 0, 0, 1, 0, 0), e.translate(t.width / 2, t.height / 2), e.scale(a, a), e.rotate(this._currentAngle * Math.PI / 180), e.drawImage(this._image, -this._image.width / 2, -this._image.height / 2, this._image.width, this._image.height), t.toDataURL("image/jpeg", this.options.quality)
        }, scale: function (t) {
            if (this._currentScale += t, this._canvasBox.width * this._currentScale < 100 || this._canvasBox.height * this._currentScale < 100)return void(this._currentScale -= t);
            this._drawImage()
        }, rotate: function (t) {
            this._currentAngle += t, (this._currentAngle <= -360 || this._currentAngle >= 360) && (this._currentAngle = 0), this._drawImage()
        }, _mouseMove: function () {
            var t = this, e = !1;
            t._canvasBox.onmousedown = function (i) {
                var s = t._getMousePos(i);
                t._startX = s.x, t._startY = s.y, e = !0
            }, t._canvasBox.onmousemove = function (i) {
                if (!0 === e) {
                    var s = t._getMousePos(i), n = s.x, a = s.y;
                    t._element.translate(n - t._startX, a - t._startY), t._drawImage(), t._startX = n, t._startY = a
                }
            }, t._canvasBox.onmouseup = function (t) {
                e = !1
            }
        }, _mouseWheel: function () {
            var t = this;
            this._canvasBox.onmousewheel = function (e) {
                e = event || window.event, e.wheelDelta > 0 ? t.scale(.1) : t.scale(-.1)
            }
        }, _bindEvt: function () {
            this.options.isMoving && this._mouseMove(), this.options.isMouseWheel && this._mouseWheel()
        }
    }, t.CanvasView = i
}(window), function (t, e, i, s) {
    "use strict";
    function n(t, i) {
        var n, o = $(t.target), r = o.parents(".imageModal");
        try {
            n = t.target.files[0]
        } catch (l) {
            return
        }
        if (n !== s) {
            if (i.maxSize && n.size / 1e6 > i.maxSize)return $().inform({
                type: "error",
                title: "图片不能超过" + i.maxSize + "M",
                delay: 2e3,
                size: "large"
            }), void o.val("");
            r.removeClass("fail").removeClass("uploaded").removeClass("optShow").removeClass("optHover").removeClass("success").addClass("uploading");
            var h = new FileReader;
            h.readAsDataURL(n), h.onload = function (t) {
                var s = t.target.result;
                if (!i.isReduce)return void a(i, s, o);
                var n = new e({src: s, maxImageW: i.maxWidth, maxImageH: i.maxHeight});
                o.val("");
                var r = setInterval(function () {
                    if (n.isComplete()) {
                        clearInterval(r);
                        var t = n.saveUrl();
                        a(i, t, o)
                    }
                }, 10)
            }
        }
    }

    function a(t, e, i) {
        switch (!0) {
            case!!t.route:
                o(i, e, t);
                break;
            case!!t.onComplete:
                t.onComplete(e), i.parents(".imageModal").removeClass("uploading").removeClass("fail");
                break;
            default:
                h(i, e, t)
        }
    }

    function o(t, e, s) {
        var n = e.substr(e.indexOf("/9j")), a = i(n);
        $.post(s.route, {sign: a, source: n}, function (e) {
            1 == e.status ? s.onComplete && s.onComplete(e.data) || h(t, e.data, s) : (t.val(""),  t.parents(".imageModal").removeClass("uploading").removeClass("uploaded").removeClass("optShow").removeClass("optHover").removeClass("success").addClass("fail"))
        }).error(function () {
            t.val(""), t.parents(".imageModal").removeClass("uploading").removeClass("uploaded").removeClass("optShow").removeClass("optHover").removeClass("success").addClass("fail")
        })
    }

    function r(t) {
        t.stopPropagation();
        var e = $(this), i = $(".imgShowBackdrop"), s = null, n = null;
        i.length ? (s = $(".imgZoomShow"), n = s.find("img")) : (i = $("<div>"), s = $("<div>"), n = $("<img/>"), i.addClass("imgShowBackdrop"), s.addClass("imgZoomShow").append(n), $("body").append(i), i.after(s)), n.attr("src", e.attr("src")), i.show(), s.show()
    }

    function h(t, e, i) {
        var s = t.parents(".imageModal");
        t.data("src", e), s.removeClass("uploading").removeClass("fail").addClass("uploaded").addClass("success").find("img").attr("src", e).data("src", e), setTimeout(function () {
            i.optAreaHover ? s.addClass("optHover") : s.addClass("optShow")
        }, 3e3)
    }
    //在h函数的基础上添h1函数，避免图片展示时出现“上传成功”
    function h1(t, e, i) {
        var s = t.parents(".imageModal");
        t.data("src", e), s.removeClass("uploading").removeClass("fail").addClass("uploaded").addClass("success").find("img").attr("src", e).data("src", e), i.optAreaHover ? s.addClass("optHover") : s.addClass("optShow")
    }

    function l(t, e) {
        var i = $(t.target), s = i.parents(".imageModal"), n = s.siblings(".imageModal").not(".demo");
        s.hasClass("disabled") || (0 == n.length ? s.removeClass("uploaded").removeClass("optShow").removeClass("optHover").removeClass("success").find("input:file").data("src", "").end().find("img").attr("src", "").data("src", "") : s.remove(), e.onDelete && e.onDelete())
    }

    function c(t, e) {
        if (!t.parents(".imageModal").hasClass("disabled")) {
            var i = t.attr("src").trim();
            e.onEdit && e.onEdit(i)
        }
    }

    function d(t) {
        return this.each(function () {
            var e = $(this), i = e.data("imgupload"), s = "object" == typeof t && t;
            i || e.data("imgupload", i = new p(e, s))
        })
    }
//去除删除按钮
    var u = '<div class="imageModal">  <div class="imageBox">    <img>    <span class="imgDemoTip"></span>   ' +
        //' <span class="glyphicon glyphicon-trash middle editIcon J-delete"></span>    ' +
        '<span class="glyphicon glyphicon-repeat editIcon J-reload"></span>  </div>  <div class="uploadIcon">    <span class="uploadSign">      <span class="img-upload-logo"></span>      <span class="img-upload-tips"></span>    </span>    <p class="uploadTip"></p>  </div></div>', p = function (t, e) {
        this.option = $.extend({}, p.DEAFULT, e, t.data()), this.element = t.eq(0), this.src = this.element.data("src"), this._wrapImgModal(), t.data("imgUpload", this)
    };
    p.DEAFULT = {
        route: "",
        demoSrc: "",
        isEdit: !1,
        onEdit: s,
        maxSize: 10,
        isReduce: !0,
        maxWidth: 1600,
        maxHeight: 1200,
        onDelete: s,
        onComplete: s,
        callback: s,
        optAreaHover: !1
    }, p.prototype = {
        _wrapImgModal: function () {
            var t = this;
            t.element.hide();
            var e = $(u);
            if (t.element.before(e), e.find(".uploadTip").before(t.element.detach().show()), t.option.isEdit && e.find(".J-delete").before('<span class="glyphicon glyphicon-pencil editIcon left J-edit"></span>'), t.element.prop("disabled") && e.addClass("disabled"), e.on("click", "img", r).on("click", ".J-delete", function (e) {
                    l(e, t.option)
                }).on("click", ".J-edit", function () {
                    c($(this).parents(".imageModal").find("img"), t.option)
                }).on("change", "input:file", function (e) {
                    n(e, t.option)
                }).on("click", ".J-reload", function () {
                    e.find("input:file").trigger("click")
                }), t.option.demoSrc) {
                var i = $(u);
                e.after(i), i.addClass("uploaded demo").find("img").attr("src", t.option.demoSrc).end()
            }
            t.src && h1(t.element, t.src, t.option)
        }, toggleDisable: function (t) {
            var e = this.element.parents(".imageModal");
            t !== s && t ? (e.addClass("disabled"), e.find("input:file").prop("disabled", !0)) : (e.removeClass("disabled"), e.find("input:file").prop("disabled", !1))
        }, backfill: function (t) {
            h(this.element, t, this.option)
        }, getImgSrc: function () {
            return this.element.data("src")
        }
    }, $(document).click(function () {
        $(".imgZoomShow").hide(), $(".imgShowBackdrop").hide()
    });
    var m = $.fn.imgupload;
    $.fn.imgupload = d, $.fn.imgupload.Constructor = p, $.fn.imgupload.noConflict = function () {
        return $.fn.imgupload = m, this
    }, $(function () {
        $('[data-toggle="imgupload"]').imgupload()
    })
}(window, CanvasView, md5);
